package com.gxa.meiye.admin.filter;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.shiro.web.filter.authc.UserFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author chen
 * @date 2022/6/29 11:13
 */
public class LoginFilter extends UserFilter {

    @Override
    protected void redirectToLogin(ServletRequest request, ServletResponse response) throws IOException {
        //super.redirectToLogin(request, response);
        response.setContentType("application/json;charset=utf8");
        Map map = new HashMap();
        map.put("code","52000");
        map.put("msg","未登录");
        ObjectMapper objectMapper = new ObjectMapper();
        String string = objectMapper.writeValueAsString(map);
        response.getWriter().write(string);

    }
}
